<template>
    <div  class="login" >
        <div class="login-box">
            <div class="box-left">
                <img width="80%" src="../assets/bg3.png" alt="">
            </div>
            <div class="box-right">
                <a-form
                style="width:100%"
                    id="components-form-demo-normal-login"
                    :form="ruleForm"
                    class="login-form"
                   
                >
                    <h3 class="login-title">xxx管理平台</h3>
                    <div style="padding:25px  50px 5px 50px">
                        <a-form-item>
                        <a-input
                            v-model="ruleForm.username"
                            placeholder="请输入用户名"
                        >
                            <a-icon slot="prefix" type="user" style="color: rgba(0,0,0,.25)" />
                        </a-input>
                        </a-form-item>
                        <a-form-item>
                        <a-input
                            v-model="ruleForm.password"
                            type="password"
                            placeholder="请输入密码"
                        >
                            <a-icon slot="prefix" type="lock" style="color: rgba(0,0,0,.25)" />
                        </a-input>
                        </a-form-item>
                        <a-form-item>
                            <a-button type="primary" html-type="submit" class="login-form-button" style="width:100%" @click="submitForm">
                                登录
                            </a-button>
                        </a-form-item>
                    </div>
                </a-form>
            </div>
        </div>
    </div>
</template>

<script>
    import { mapMutations } from 'vuex';
    import axios from 'axios';
    // import { fairList } from '../http/api'
    // import { AForm } from 'ant-design-vue';
    export default {
        data: function(){
            return {
                dialogVisible:false,
                dialog:'',
                ruleForm: {
                    username: '',
                    password: ''
                },
                
            }
        },
        beforeCreate() {
            
        },
        methods: {
            ...mapMutations(['set_name',]),
            submitForm(){

                if(this.ruleForm.username ==''){
                     this.$message.info('请输入用户名');
                     return
                }
                if(this.ruleForm.password ==''){
                     this.$message.info('请输入密码');
                     return
                }
                let data= {
                            password:this.ruleForm.password,
                            username: this.ruleForm.username,
                        }
                        // fairList(data).then((res) => {        
                        // if(res.data.code == 0){
                        //         let list = res.data.data
                                sessionStorage.setItem('accessToken', "1");
                        //         sessionStorage.setItem('refreshToken', list.refreshToken);
                        //         sessionStorage.setItem('name', list.name);
                        //         this.set_name(list.name)
                        //         sessionStorage.setItem('id', list.id);
                        //         this.$router.push('/mainPage')
                        // }
                        // else{
                        //     this.$message.error(res.data.msg);
                        // }
                    // })
                    sessionStorage.setItem('accessToken', "1");//假token
                    this.$router.push('/mainPage')
                // e.preventDefault();
                // this.ruleForm.validateFields((err, values) => {
                //     if (!err) {
                //     console.log('Received values of form: ', values);
                //     }
                // });
            }
        }
    }
</script>

<style scoped>
    .login{
        background-image: url('../assets/bg1.png');
        background-repeat: no-repeat;
        background-size: 100% 100%;
        width: 100%;
        height:100%;
        position: relative;
    }
    .login-box {
        position: relative;
        left: 50%;
        top: 50%;
        transform: translate(-50%,-50%);
        background-color: #ffffff;
        width: 925px;
        height: 455px;
        box-shadow: 5px 5px 10px 10px rgba(0, 0, 0, 0.2);
        display: flex;
        justify-content: space-between;
        border-radius: 10px;
    }
    .box-left{
        width:50%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .box-right{
        width: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .login-title {
        text-align: center;
        margin:0;
        color: #000;
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
    }
    .showtext{
        line-height:40px;
        color:#000000;
        margin:0 0 0 20px;
        float:left
    }
    .loginshow /deep/ .el-input__inner{
        background-color:#fff;
        color:#000
    }
</style>
